Imports System.Windows.Forms
Imports Vintasoft.Imaging

Namespace Imaging
	Public Partial Class SelectImageForm
		Inherits Form

		#Region "Fields"

		Private _images As ImageCollection

		#End Region



		#Region "Constructors"

		Public Sub New()
			InitializeComponent()
		End Sub

		Public Sub New(images As ImageCollection)
			Me.New()
			_images = images
			selectedImageNumericUpDown.Maximum = images.Count
			thumbnailViewer1.Images.AddRange(images.ToArray())
		End Sub

		#End Region



		#Region "Properties"

		Public Property SelectedImageIndex() As Integer
			Get
				Return CInt(Math.Truncate(selectedImageNumericUpDown.Value)) - 1
			End Get
			Set
				selectedImageNumericUpDown.Value = value + 1
			End Set
		End Property

		#End Region



		#Region "Methods"

		Private Sub buttonOk_Click(sender As Object, e As EventArgs)
			DialogResult = DialogResult.OK
		End Sub

		Private Sub buttonCancel_Click(sender As Object, e As EventArgs)
			DialogResult = DialogResult.Cancel
		End Sub

		Private Sub thumbnailViewer1_FocusedIndexChanged(sender As Object, e As FocusedIndexChangedEventArgs)
			selectedImageNumericUpDown.Value = e.FocusedIndex + 1
		End Sub

		Private Sub selectedImageNumericUpDown_ValueChanged(sender As Object, e As EventArgs)
			thumbnailViewer1.FocusedIndex = SelectedImageIndex
		End Sub

		#End Region


	End Class
End Namespace
